package unq.tpi.persistencia.performanceEj.daos;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.classic.Session;

import unq.tpi.persistencia.performanceEj.model.Employee;
import unq.tpi.persistencia.performanceEj.model.Salary;
import unq.tpi.persistencia.util.SessionManager;


public class SalaryDAO {
    
    @SuppressWarnings("unchecked")
    public List<Salary> getOrderBySalary(){
        Session session = SessionManager.getSession();
        Query q = session.createQuery("from Salary order by salary desc");
        
        return q.setMaxResults(10).list();
    }
    
    public Employee getEmployeesFromSalary (int emp_no){      
            Session session = SessionManager.getSession();
            Query q = session.createQuery("from Employee where emp_no = :emp_no");
            
            q.setParameter("emp_no", emp_no);
            
            return (Employee)q.uniqueResult();
        }

}
